package db

import (
	"context"

	"github.com/redis/go-redis/v9"
)

type RedisClient struct {
	client *redis.Client
}

func NewRedisClient(addr, password string, db int) *RedisClient {
	client := redis.NewClient(&redis.Options{
		Addr:     addr,
		Password: password,
		DB:       db,
	})
	return &RedisClient{
		client: client,
	}
}

func (r *RedisClient) Get(key string) (interface{}, error) {
	ctx := context.Background()
	return r.client.Get(ctx, key).Result()
}

func (r *RedisClient) Set(key string, value interface{}) error {
	ctx := context.Background()
	return r.client.Set(ctx, key, value, 0).Err()
}
